package com.test.example.controller.log;

import com.xingluo.tools.log.entity.OperateLog;
import com.xingluo.tools.log.handler.LogHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class LogHandler extends LogHandlerAdapter {
    @Override
    public void handle(OperateLog operateLog) {
        if (operateLog.getStatus().equals("正常")){
            log.info("{}, 请求IP: {}, API: {}, MethodName: {}, Method: {}, Params: {}, 耗时: {}",
                    operateLog.getOperateTime(),
                    operateLog.getIp(),
                    operateLog.getUri(),
                    operateLog.getMethodName(),
                    operateLog.getMethod(),
                    operateLog.getParams(),
                    operateLog.getUseTime()+"ms");
        }else {
            log.error(operateLog.toString());
        }
    }
}
